/**
 * Created by Richard Radlherr.
 * Date: 10.06.2006 19:00
 */

using System;
using TagTool.Core;
using TagTool.GraphicTypes;

namespace TagTool.Nodes.Math
{

	public class Addition : BaseNode
	{
		private InputSlot slotA;
		private InputSlot slotB;
		private OutputSlot slotC;

		public Addition() : base()
		{
			Name = "Addition";
			slotA = new InputSlot(this, "A", 0.0);
			slotB = new InputSlot(this, "B", 1.0);
			slotC = new OutputSlot(this, "Result", typeof(Double));
			slotA.ParseCallback = ParseHelper.ParseDouble;
			slotB.ParseCallback = ParseHelper.ParseDouble;
			slotC.Value = 0.0;
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotB
		{
			get { return slotB; }
		}

		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotC
		{
			get { return slotC; }
		}

		public override void Update(Object sender)
		{
			slotC.Value = (double)slotA.Value + (double)slotB.Value;
		}

	}
	
	public class Subtraction : BaseNode
	{
		private InputSlot slotA;
		private InputSlot slotB;
		private OutputSlot slotC;

		public Subtraction() : base()
		{
			Name = "Subtraction";
			slotA = new InputSlot(this, "A", 0.0);
			slotB = new InputSlot(this, "B", 1.0);
			slotC = new OutputSlot(this, "Result", typeof(Double));
			slotA.ParseCallback = ParseHelper.ParseDouble;
			slotB.ParseCallback = ParseHelper.ParseDouble;
			slotC.Value = 0.0;
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotB
		{
			get { return slotB; }
		}

		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotC
		{
			get { return slotC; }
		}

		public override void Update(Object sender)
		{
			slotC.Value = (double)slotA.Value - (double)slotB.Value;
		}

	}
}
